package com.atguigu.springboot.controller;

import com.atguigu.springboot.bean.Department;
import com.atguigu.springboot.mapper.DepartmentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : leimingchao
 * @date Date : 2021年10月17日 11:05
 */
@RestController
public class DepartmentController {

    @Autowired
    private DepartmentMapper departmentMapper;

    @GetMapping(value = "/department/{id}")
    public Department getDepartment(@PathVariable(value = "id") Integer id) {
        return departmentMapper.getDepartmentById(id);
    }

    @GetMapping(value = "/department")
    public Department insertDepartment(Department department) {
        departmentMapper.insertDepartment(department);

        return department;
    }
}
